package edu.egypt.contextmenu;

import android.app.Activity;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.Button;
import android.widget.Toast;

public class ContextMenuSampleActivity extends Activity {

	private Button button;
	

	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        button = (Button)findViewById(R.id.button1);
        registerForContextMenu(button);
        
    }


	@Override
	public void onCreateContextMenu(ContextMenu menu, View v,
			ContextMenuInfo menuInfo) {		
		super.onCreateContextMenu(menu, v, menuInfo);
		
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.options_menu, menu);
		
	}


	@Override
	public boolean onContextItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case R.id.camera_item:
			Toast.makeText(this, "You Selected the Camera", Toast.LENGTH_SHORT).show();
			return true;
		case R.id.add_item:
			Toast.makeText(this, "You Selected the Add", Toast.LENGTH_SHORT).show();
			return true;
		case R.id.compass_item:
			Toast.makeText(this, "You Selected the Compass", Toast.LENGTH_SHORT).show();
			return true;
		default:
			return super.onContextItemSelected(item);
		}
		
		
	}
	
	
	
	
}